package java8.lambda;

import javafx.scene.control.Button;
import org.aspectj.apache.bcel.classfile.annotation.RuntimeAnnos;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author vivi20
 * @ClassName Lamdba
 * @Date 2019/12/31 11:24
 * @Vertion 1.0
 */
public class Lamdba {

    public static void main(String[] args) {
//        String[] aaa;
//        String[] bbb;
//        (String first,String secend)->Integer.compare(first.length(),secend.length());
//        String first;
//        String secend;
//        (String first,String secend)->{
//            if (first.length()<secend.length()) return -1;
//            else if(first.length()>secend.length()) return 1;
//            else return 0;
//        }
//        ()->{ for (int i = 0; i < 1000; i++) doWork(); }
//       Runnable sleeper = ()->{
//           System.out.println("ZZZ");
//           Thread.sleep(1000);
//       };
//        Callable<Void> able = () -> {
//            System.out.println("ZZZ");
//            Thread.sleep(1000);
//            return null;
//        };
//
//        Runnable sleeper = () -> {
//            System.out.println("ZZZ");
//            try {
//                Thread.sleep(1000);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//        };
//
//        Button button = new Button();
//        button.setOnAction(event -> System.out.println(event));
//        button.setOnAction(System.out::println);
//        String[] strings = null;
//        Arrays.sort(strings,String::compareToIgnoreCase);

//        double x = 0L;
//        double y = 0L;
//        System.out.println(Math.pow(x,y));

//        List<String> labels = new ArrayList<>();
//        Stream<Button> stream = labels.stream().map(Button::new);
//        List<Button> buttons = stream.collect(Collectors.toList());
//        System.out.println(buttons);
//
//        Object[] buttonss = stream.toArray();
//        Button[] buttonsss = stream.toArray(Button[]::new);

        repeatMessage("Hello",1000);



    }

    public static void doWork() { };

    public static void button(){
        Button button = new Button();
        button.setOnAction(System.out::println);
    }

    public static void repeatMessage(String text,int count){
        Runnable r = ()->{
            for (int i = 0; i < count; i++){
                System.out.println(text);
                Thread.yield();
            }
        };
        new Thread(r).start();
    }

//    public static void repeatMessage1(String text,int count){
//        Runnable r = ()->{
//            while (count>0)
//            count--;
//            System.out.println(text);
//            Thread.yield();
//        };
//        new Thread(r).start();
//    }

public static void test(){
        //Path first = Paths.get("/user/bing");
    Comparator<String> comp = (first,second)->Integer.compare(first.length(),second.length());
}






}
